package lec02.am.ex;

public class ArraySolver {

	private static final int SIZE = 100;
	static long H[];
	
	static void fill(){
		H=new long[SIZE+1];
		for (int i = 1; i < H.length; i++) {
			H[i]=h(i);
		}
	}

	public static void solve() {
		fill();
		int a, b, c, d, e, f;
		for (a = 1; a <= SIZE; a++)
			for (b = a; b <= SIZE; b++)
				for (c = b; c <= SIZE; c++)
					for (d = c; d <= SIZE; d++)
						for (e = d; e <= SIZE; e++)
							for (f = e + 1; f <= SIZE; f++) {
								if (H[a] + H[b] + H[c] + H[d] + H[e] == H[f]) {
									System.out.println(String.format(
											"%d^5+%d^5+%d^5+%d^5=%d^5",
											a, b, c, d, e, f));
								}
							}

	}

	private static long h(int a) {
		return 1L * a * a * a * a * a;
	}

}
